package com.jwb.pub.daoImpl;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.stereotype.Repository;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import java.io.IOException;
public class MybatisSessionFactory {
	@Autowired
   	private SqlSessionFactory sessionFactory;



	public SqlSessionFactory getSqlSessionFactory() {
		return sessionFactory;
	}

	public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
		this.sessionFactory = sqlSessionFactory;
		
	}

	public SqlSession getSession() {
		
		return sessionFactory.openSession();
	}
	
	public void closeSession(SqlSession session) {
		if (session != null) {
			session.close();
			session = null;
		}
	}

}   
